# -*- coding:utf8 -*-
# __author__ = "zhangying"
# __date__ = "2019/2/18 16:02"
#调用定位信息
from util.read_init import ReadIni


class GETBYLOCAl:
    def __init__(self,driver):
        self.driver = driver

    def get_element(self,key):
        #id>cn.com.open.mooc:id/account_edit
        read_ini = ReadIni()
        local = read_ini.get_value(key)
        if local != None:
            by = local.split('>')[0]
            local_by = local.split('>')[1]
            try:
                if by == 'id':
                    return  self.driver.find_element_by_id(local_by)
                elif by == 'className':
                    return self.driver.find_element_by_class(local_by)
                else:
                    return self.driver.find_element_by_xpath(local_by)
            except:
                return None
        else:
            return None


